//import java.util.Scanner;
//
///**
// * @Author Stringzhua
// * @Date 2024/10/10 19:23
// * description:
// */
//public class test {
//    public static void main(String[] args) {
////////        double math,chinese,english;
////////        Scanner sc = new Scanner(System.in);
////////        math = sc.nextDouble();
////////        chinese = sc.nextDouble();
////////        english = sc.nextDouble();
////////
////////        double avgScore=(math+chinese+english)/3;
////////        double totalScore=math+chinese+english;
////////        System.out.printf("%.2f %.2f",totalScore,avgScore);
//////
////////        int a = 3;
////////        double c = (a + (a >> 1)) * 1.5; // 先计算 a + a >> 1，然后乘以 1.5
////////        System.out.println(c); // 打印结果
//////
//////        int a = 3;
//////        double c = (a + (a >> 1)) / 1.5; // 先计算 a + a >> 1，然后除以 1.5
//////        System.out.println(c); // 打印结果
////        long num = 3735928559l;
////        char ch = (char)num;
////        System.out.println(ch);
//
//    }
//}
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;

public class RC4EncryptionExample {
    public static String encrypt(String key, String data) throws Exception {
        Cipher cipher = Cipher.getInstance("RC4");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "RC4");
        cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
        byte[] encryptedBytes = cipher.doFinal(data.getBytes());
        return Base64.getEncoder().encodeToString(encryptedBytes);
    }

    public static void main(String[] args) throws Exception {
        String key = "mysecretis123456";
        String data = "coder_yupi + mysecretis123456";
        String encryptedData = encrypt(key, data);
        System.out.println("加密后的结果：" + encryptedData);
    }
}